<?php

declare(strict_types=1);

namespace Modules\Purchasing\Models;

use Catch\Base\CatchModel as Model;

/**
 * @property $id
 * @property $creator_id
 * @property $created_at
 * @property $updated_at
 * @property $deleted_at
*/
class Purchaseorderschedule extends Model
{
    

    

    protected $table = 'purchaseorderschedule';

    protected $fillable = [ 'id', 'creator_id', 'created_at', 'updated_at', 'deleted_at', 'fid', 'fseq', 'fentryid', 'fmaterialid', 'fmaterialname', 'fmaterialmodel' , 'fmodel' , 'funitid_number' , 'funitid_name' , 'fqty' , 'fdeliverydate', 'fmemo', 'returnquantity', 'quantity_in', 'state','fownertypeid','fownerid_number','fownerid_name','fmasterid','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    protected array $fields = ['id','created_at','updated_at', 'fid', 'fseq', 'fentryid', 'fmaterialid', 'fmaterialname', 'fmaterialmodel' , 'fmodel' , 'funitid_number' , 'funitid_name' , 'fqty' , 'fdeliverydate', 'fmemo', 'returnquantity', 'quantity_in', 'state','fownertypeid','fownerid_number','fownerid_name','fmasterid','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

    /**
     * @var array
     */
    protected array $form = ['created_at','updated_at', 'fid', 'fseq', 'fentryid', 'fmaterialid', 'fmaterialname', 'fmaterialmodel' , 'fmodel' , 'funitid_number' , 'funitid_name' , 'fqty' , 'fdeliverydate', 'fmemo', 'returnquantity', 'quantity_in', 'state','fownertypeid','fownerid_number','fownerid_name','fmasterid','fields1','fields2','fields3','fields4','fields5','fields6','fields7','fields8','fields9','fields10'];

      /**
     * @var array
     */
    public array $searchable = [
        'fmaterialid' => 'like',
        'fmaterialmodel' => 'like',
        'funitid_number' => 'like',
    ];

   
    public static function getData($fields,$where){
        return self::select($fields)->where($where)->first();
    }

    public static function getDatajon($fields,$where){
        return self::select($fields)
        ->join('purchaseorder as purchaseorder','purchaseorder.id','=','purchaseorderschedule.purchaseorder_id')
        ->where($where)->first();
    }

    
}
